package com.arica.project.elacticsearch.domain;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.frameworkset.orm.annotation.Column;
import com.frameworkset.orm.annotation.ESId;
import org.frameworkset.elasticsearch.entity.ESBaseData;

import java.util.Date;
import java.util.Objects;

public class CrudEsDemo extends ESBaseData {
    private Object dynamicPriceTemplate;
    //Set the document identity field
    @ESId(readSet = true,persistent = false)
    private Long demoId;
    private String contentbody;
    /**  When the date format is specified in the mapping definition,
     *  the following two annotations need to be specified, for example:
     *
     "agentStarttime": {
     "type": "date",
     ###Specify multiple date formats
     "format":"yyyy-MM-dd HH:mm:ss.SSS||yyyy-MM-dd'T'HH:mm:ss.SSS||yyyy-MM-dd HH:mm:ss||epoch_millis"
     }
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
     @Column(dataformat = "yyyy-MM-dd HH:mm:ss.SSS")
     */

    protected Date agentStarttime;



    public Date getAgentStarttimezh() {
        return agentStarttimezh;
    }

    public void setAgentStarttimezh(Date agentStarttimezh) {
        this.agentStarttimezh = agentStarttimezh;
    }

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Column(dataformat = "yyyy-MM-dd HH:mm:ss")
    private Date agentStarttimezh;
    private String applicationName;
    private String orderId;
    //	@JsonProperty(value="contrast_status",access= JsonProperty.Access.WRITE_ONLY)
    private int contrastStatus;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    private String name;

    public String getContentbody() {
        return contentbody;
    }

    public void setContentbody(String contentbody) {
        this.contentbody = contentbody;
    }

    public Date getAgentStarttime() {
        return agentStarttime;
    }

    public void setAgentStarttime(Date agentStarttime) {
        this.agentStarttime = agentStarttime;
    }

    public String getApplicationName() {
        return applicationName;
    }

    public void setApplicationName(String applicationName) {
        this.applicationName = applicationName;
    }

    public Long getDemoId() {
        return demoId;
    }

    public void setDemoId(Long demoId) {
        this.demoId = demoId;
    }

    public Object getDynamicPriceTemplate() {
        return dynamicPriceTemplate;
    }

    public void setDynamicPriceTemplate(Object dynamicPriceTemplate) {
        this.dynamicPriceTemplate = dynamicPriceTemplate;
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public int getContrastStatus() {
        return contrastStatus;
    }

    public void setContrastStatus(int contrastStatus) {
        this.contrastStatus = contrastStatus;
    }


    public static CrudEsDemo build(CrudEsDemo demo) {
        if (Objects.isNull(demo.getDemoId())) {
            demo.setDemoId(2l);//Specify the document id, the unique identity, and mark with the @ESId annotation. If the demoId already exists, modify the document; otherwise, add the document
            demo.setAgentStarttime(new Date());
            demo.setAgentStarttimezh(new Date());
            demo.setApplicationName("blackcatdemo2");
            demo.setContentbody("this is content body2");
            demo.setName("liudehua");
            demo.setOrderId("NFZF15045871807281445364228");
            demo.setContrastStatus(2);
            System.out.println(JSONObject.toJSONString(demo));
        }
        return demo;
    }
}
